package event;

import java.util.ArrayList;

public final class Event<T extends EventArgs> {
    private ArrayList<IEventHandler<T>> observerList = new ArrayList<IEventHandler<T>>();

    public void raise(Object sender, T e) {
        for(IEventHandler<T> handler : this.observerList) {
            handler.eventReceived(sender, e);
        }
    }

    public void add(IEventHandler<T> handler) {
        this.observerList.add(handler);
    }

    public void remove(IEventHandler<T> handler) {
        this.observerList.remove(handler);
    }
}